namespace org.jawk.util
{
	/// <summary>A simple delegate to a LinkedList.</summary>
	/// <remarks>
	/// A simple delegate to a LinkedList.  Unlike the java.util.Stack,
	/// this implementation is non-synchronized to improve performance.
	/// <p>
	/// It performs slower than the ArrayStackImpl version.
	/// <p>
	/// There is no maximum capacity which is enforced, nor is there any
	/// checks if pop() is executed on an empty stack.
	/// </remarks>
	[System.Serializable]
	public class LinkedListStackImpl<E> : System.Collections.Generic.LinkedList<E>, org.jawk.util.IMyStack<E>
	{
		public void Push(E o)
		{
			AddFirst(o);
		}

		public E Pop()
		{
            E elt = First.Value;
			RemoveFirst();
            return elt;
		}

        public int Size()
        {
            return Count;
        }

        public E Peek()
        {
            return First.Value;
        }
    }
}
